package cn.digger.md2pdf.controller;

import cn.digger.md2pdf.service.Md2PdfService;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/md2pdf")
public class Md2PdfController {

    @Resource
    private Md2PdfService md2PdfService;

    @PostMapping("/convert")
    public ResponseEntity<ByteArrayResource> convertMdToPdf(@RequestParam("file") MultipartFile file) throws IOException {
        return md2PdfService.convertMdToPdf(file);
    }
}